package com.example.springsecuritystudy.controller;

import com.example.springsecuritystudy.emuns.User;
import com.example.springsecuritystudy.service.impl.UserServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LiuZiMing
 * @since 2024-01-05
 */
@RestController
@Tag(name = "user")
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @GetMapping("/test")
    @Operation(summary = "测试")
    public String test(){
        return "用户密码验证通过";
    }

    @GetMapping("/")
    @Operation(summary = "根据用户名获取用户")
    public UserDetails getUserByUserName(String username) {
        return userService.loadUserByUsername(username);
    }
}
